home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / pcmag / v10n16 / pinv.prg < prev    next >
Encoding:
Text File  |  1991-08-27  |  3.6 KB  |  107 lines

  1. ***********************************************************************
  2. * PINVOICE.PRG                             for FoxPro 1.02
  3. * Sample program to demonstrate use of the atsay function.
  4. ***********************************************************************
  5. uon   = CHR(27)+"&d0D"           && Turn on underline
  6. uoff  = CHR(27)+"&d0@"           && Turn off underline
  7. =ljsetup()                       && Reset Laserjet
  8.  
  9. =helv(12)                        && Select Helvetica 12pt.
  10.  
  11. USE pinv
  12. =atsay(2, 1, "Custno: ")
  13. =atsay(2, 9, custno)
  14. =atsay(2, 35, "Item")
  15. =atsay(3, 35, uon+" No. "+uoff)
  16. =atsay(3, 41, uon+"Qty.  "+uoff)
  17. =atsay(3, 47, uon+"Cost       "+uoff)
  18. =atsay(3, 56, uon+"Total        "+uoff)
  19.  
  20. =helvi(12)                       && Select Helv 12pt. Italic
  21.  
  22. =atsay(5, 1, "This is an example of lining up numeric")
  23. =atsay(6, 1, "output using a proportional font on an")
  24. =atsay(7, 1, "HP Laserjet Series printer.")
  25. =atsay(10, 1, "Payment is overdue.")
  26. =atsay(0, 25, "I N V O I C E    D E T A I L S")
  27.  
  28. =helv(12)                        && Select Helvetica 12pt.
  29.  
  30. m.custno = custno
  31. m.row = 5                        && Start with line 5
  32. gtotal = 0                       && Print details
  33. DO WHILE m.custno = custno
  34.   =atsay(m.row, 35, itemno)
  35.   =atsay(m.row, 41, qty, "999")
  36.   =atsay(m.row, 45, cost, "9,999.99")
  37.   =atsay(m.row, 53, cost*qty, "999,999.99")
  38.   gtotal = gtotal + (cost*qty)
  39.   m.row = m.row + 1
  40.   SKIP
  41. ENDDO
  42. m.row = m.row + 2
  43. =atsay(m.row, 28, "Total:")
  44. =atsay(m.row, 51, gtotal, "$,$$$,999.99")
  45. EJECT
  46. =ljsetup()                       && Reset Laserjet
  47. USE
  48. RETURN
  49.  
  50. FUNCTION ljsetup
  51. ??? CHR(27) + "E"                && Resets Laserjet to front panel defaults
  52. RELEASE lpi, pitch
  53. PUBLIC lpi, pitch
  54. lpi = 6                          && Set up lines per inch
  55. pitch = 10                       && Set up pitch (characters per inch)
  56. RETURN ""
  57.  
  58. FUNCTION helv
  59. PARAMETERS point
  60. ??? CHR(27) + "&l0O" + CHR(27) + "(0U" + CHR(27) + "(s1p" + ;
  61.   LTRIM(STR(point,5,2)) + "v0s0b4T"
  62. RETURN
  63.  
  64. FUNCTION helvi
  65. PARAMETERS point
  66. ??? CHR(27) + "&l0O" + CHR(27) + "(0U" + CHR(27) + "(s1p" + ;
  67.   LTRIM(STR(point,5,2)) + "v1s0b4T"
  68. RETURN
  69.  
  70.  
  71. ***********************************************************************
  72. * FUNCTION atsay
  73. *
  74. * Use HP LJ vertical and horizontal decipoint positioning to place
  75. * character or numeric output on a page.
  76. *
  77. * Requires PUBLIC variables pitch and lpi.
  78. *
  79. ***********************************************************************
  80. FUNCTION atsay
  81. PARAMETERS mrow, mcol, fieldval, pictval
  82.  
  83. move_hor = ROUND(720/pitch, 2)         && Relative horizontal move value
  84. hor = 720/pitch * mcol                 && Horizontal position based on @ SAY value
  85. ver = LTRIM(STR(720/lpi * mrow, 5, 2)) && Vertical position based on @ SAY value
  86.  
  87. IF TYPE("pictval") = "C"               && "L" if not provided
  88.    fieldval = TRANSFORM(fieldval, pictval)   && Transform the number
  89.    no_chars = LEN(fieldval)            && Calculate length of field
  90.    ??? CHR(27) + "&a" + LTRIM(STR(hor,5,2)) + "h" + ver + "V"
  91.    *
  92.    * Calculate rightmost character position
  93.    *
  94.    end_hor = hor + (move_hor * no_chars)
  95.    *
  96.    * Calculate leftmost character position allowing 90% of pitch value
  97.    * for each character
  98.    new_pos = end_hor - (move_hor * no_chars * .9)
  99.    FOR char = 1 TO no_chars
  100.       ??? CHR(27) + "&a" + LTRIM(STR(new_pos,5,2)) + "H" + SUBSTR(fieldval,char,1)
  101.       new_pos = new_pos + (move_hor * .9)       && Calculate next character position
  102.    ENDFOR
  103. ELSE
  104.    ??? CHR(27) + "&a" + LTRIM(STR(hor,5,2)) + "h" +  ver + "V" + fieldval
  105. ENDIF
  106. RETURN ""
  107.